/**
 *  Copyright (c)  2011-2020 Panguso, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Panguso, 
 *  Inc. ("Confidential Information"). You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into with Panguso.
 */

package cn.edu.thu.log.terminal;

import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.List;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 
 * @author fenyo
 */
public final class MapReduceTerminal {
	private static String hadooppath = "/data/bcpdm/hadoop-0.20.2";
	
	private MapReduceTerminal() {
		
	}
/**
 * 
 * @param jarfile parameter
 * @param inputfilepath parameter
 * @param outputfilepath parameter
 * @throws Exception  异常处理
 */
	public static void xesConvertor(String jarfile, String inputfilepath,
			String outputfilepath) throws Exception {
		String[] shellcommand = new String[4];
		shellcommand[0] = "/bin/sh";
		shellcommand[1] = "-c";
		shellcommand[2] = "cd " + hadooppath;
		shellcommand[3] = "bin/hadoop jar " + jarfile + " " + inputfilepath
				+ " " + outputfilepath;
		Process process;
		process = Runtime.getRuntime().exec(shellcommand, null, null);
		InputStreamReader ir = new InputStreamReader(process.getInputStream());
		LineNumberReader input = new LineNumberReader(ir);
		process.waitFor();
		List<String> strList = new ArrayList<String>();
		String line;
		while ((line = input.readLine()) != null) {
			strList.add(line);
		}
		for (int i = 0; i < strList.size(); i++) {
			// System.out.println(strList.get(i));
			System.out.println("test");
		}

	}
/**
 * 
 * @param args parameter
 * @throws Exception 异常处理
 */
	public static void main(String[] args) throws Exception {
		MapReduceTerminal.xesConvertor("Test_reduce15.jar",
				"/tmp/input_big/input_big", "/tmp/outputPM_big_big_big");
	}
}
